var _userInfo = null;

function menuLoginCallBack() {
	getUserInfo(showMenuLoginStatus);
}

function getUserInfo(callback) {
	$.ajax({
		type: 'GET',
        url: appConfig.domain + 'user/getUserInfo',
        dataType: 'json',
        error: function (r){},
        success: function(userinfo){
    		if (callback) {
    			callback(userinfo);
    		}
        }
	});
}

function showMenuLoginStatus(userinfo) {
	if (userinfo.code == 0) {
		_userInfo = userinfo.data;
		$('#c_m_nickname').text(userinfo.data.nickname);
		$('#c_m_score').text(userinfo.data.score);
		$('#c_m_vote').text(userinfo.data.vote);
		$('.nav_right_2').hide();
		$('.nav_right_1').show();
	} else {
		$('.nav_right_1').hide();
		$('.nav_right_2').show();
	}
}

function exchange(id) {
	loader('service/exchange',function(){
		$app.exchange._callback = function(r){
			if (r.code == 0) {
				mopen('yhc', {from:'id'});
			} else if (r.code == 1)  {
				mopen('yh', {from:'id'});
			} else {
				alert(r.message);
			}
		};
		$app.exchange.score(id);
	}); 
}

function vote(id) {
	loader('service/vote',function(){
		$app.voteNoVerifycode(id, function(r){
			if (r.code == 0) {
				mopen('tp', {from:'id'});
			} else {
				alert(r.message);
			}
		});
	});
}

var   urlHost	 = "http://" + window.location.host;
var   info   =   {
		"1" :  {"title"  :"这一刻，爱吧：",
				"content":"童鞋们，我在这些爱情象限里看到了你们的影子。强烈推荐《这一刻，爱吧！》，青春爱情观点微电影！",
				"video"  :""},
		"2" :  {"title"	 :"管它爱是天使还是恶魔：",
				"content":"爱情，就是在你要放弃的时刻再坚持一下！微电影《这一刻，爱吧！》，搞定美女的不是陈柏霖三招，而是真心！",
				"video"  :"k0010WkJfJi"},
		"3" :  {"title"	 :"爱，一斤多少钱：",
				"content":"看到拜金女宝马车里的陶醉画面，吊丝表示膝盖好疼。微电影《这一刻，爱吧！》看校园版马诺倒追高富帅。",
				"video"  :"F0010MHIIdN"},
		"4" :  {"title"	 :"真爱要靠哈利波特：",
				"content":"史上最浪漫的情书，童鞋们，那些年的单纯美好还在么？《这一刻，爱吧！》，触动心灵的好微电影！",
				"video"  :"H0010zEQCCO"},
		"5" :  {"title"  :"爱，现在98度：",
				"content":"其实那些年，我们都曾以朋友的名义爱着ta。推荐微电影《这一刻，爱吧！》，制作精良，情感细腻！",
				"video"  :"o0010yV0pnC"},
		'6' :  {'title'  :"这一刻，爱吧(完整版)：",
				"content":"你相不相信爱情，是很相信，还是很不相信？对于爱情你会主动地努力争取，还是被动地静静等候？ 可爱多青春爱情观点微电影《这一刻，爱吧!》完整版，纯爱演绎！",
				"video"  :"c01001jc2h7"}
	};
var monitor = {
		'1' : {"name" : "[分享微电影]" ,		"url" : "http://t.l.qq.com/ping?t=m&cpid=641009603&url=http%3A//app_minisite_click_monitor/button6410096030"}
	};

function shareURL(e)
{	
	var content = "#7喜 谁是主角# 就算不是实力派，也该做个行动派！现在就来加入吧，只要参与投票、分享活动、邀请好友及分享视频就可获得相应气值，积累气值更能获得抽奖机会，赢取海量惊喜好礼哦！http://7up.qq.com/";
	var url = 'http://7up.qq.com/';
	var img = '';
	switch(e)
	{
		case 1:
			window.open('http://v.t.qq.com/share/share.php?title='+encodeURIComponent(content)+url+'&url='+url+
					'&source=bookmark','_blank','scrollbars=no,width=600,height=450,left=75,top=20,status=no,resizable=yes'); void 0;
			break;
		case 2:
			window.open('http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?title=&url='+url+
					'&pics=&summary='+encodeURIComponent(content),'_blank',
					'scrollbars=no,width=610,height=550,left=75,top=20,status=no,resizable=yes'); void 0;
			break;
		case 3:
			window.open('http://www.kaixin001.com/repaste/share.php?rtitle=&rurl='+url+
					'&rcontent='+encodeURIComponent(content),'_blank',
					'scrollbars=no,width=600,height=450,left=75,top=20,status=no,resizable=yes');void 0;
			break;
		case 4:
			shareClick(url,img,'',content);
			break;
		case 5:
			var u='http://www.douban.com/recommend/?url='+url+'&title='+encodeURIComponent(content);
			window.open(u,'douban','toolbar=0,resizable=1,scrollbars=yes,status=1,width=450,height=330');void(0);
			break;
		case 6:
			void((function(s,d,e,r,l,p,t,z,c){var f='http://v.t.sina.com.cn/share/share.php?c=spr_web_bd_pingan_weibo',u=z||d.location,p=['&url=',e(u),'&title=',e(t||d.title),'&source=',e(r),'&sourceUrl=',e(l),'&content=',c||'gb2312','&pic=',e(p||'')].join('');function a(){if(!window.open([f,p].join(''),'mb',['toolbar=0,status=0,resizable=1,width=440,height=430,left=',(s.width-440)/2,',top=',(s.height-430)/2].join('')))u.href=[f,p].join('');};if(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else a();})(screen,document,encodeURIComponent,'','','',content,'','页面编码gb2312|utf-8默认gb2312')); 
			break;
		case 7:
			window.open('http://v.t.qq.com/share/share.php?title='+encodeURIComponent(content)+
					'&pics='+encodeURIComponent(img)+'&source=bookmark','_blank',
					'scrollbars=no,width=600,height=450,left=75,top=20,status=no,resizable=yes'); void 0;
			break;
		case 8:
			window.open('http://t.sohu.com/third/post.jsp?url='+url+
					'&title='+encodeURIComponent(content)+
					'&content=utf-8&pic='+encodeURIComponent(img)+'&source=bookmark','_blank',
					'scrollbars=no,width=600,height=450,left=75,top=20,status=no,resizable=yes'); void 0;
			break;
		case 9:
			window.open('http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?to=pengyou&url='+url+
					'&source=bookmark','_blank','scrollbars=no,width=600,height=450,left=75,top=20,status=no,resizable=yes');void(0);
			break;
		case 10:
			window.open('http://t.163.com/article/user/checkLogin.do?source=&info='+encodeURIComponent(content)+
					'&images=&source=bookmark','_blank','scrollbars=no,width=600,height=450,left=75,top=20,status=no,resizable=yes');void(0);
			break;
	}
}

/**
 * 贴点
 * @param id
 * @return
 */
function tack(id)
{
	if (id != undefined){
		return $.getScript(monitor[id]['url']);	
	}
}

function shareClick(url,imgUrl,title,content) {
    var rrShareParam = {
        resourceUrl : url,	//分享的资源Url
        pic : imgUrl,	//分享的主题图片Url
        title : title,		//分享的标题
        description : content	//分享的详细描述
    };
    rrShareOnclick(rrShareParam);
}